package com.bestv.search.engine.compass.extend;

import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.util.PriorityQueue;

/**
 * @author Michael Wang
 */
public class CategoryHitQueue extends PriorityQueue {

    CategoryHitQueue(int size) {
        initialize(size);
    }

    @Override
    protected boolean lessThan(Object a, Object b) {
        ScoreDoc hitA = (ScoreDoc) a;
        ScoreDoc hitB = (ScoreDoc) b;
        if (hitA.score == hitB.score)
            return hitA.doc > hitB.doc;
        else
            return hitA.score < hitB.score;
    }
}
